package com.lvt.example.thinking.in.spring.questions.L24.resttemplate;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

/**
 * desc：class
 *
 * @author LT
 * @date 2022/10/25
 */
public class Test3 {
    public static void main(String[] args) {

//        RestTemplate restTemplate = new RestTemplate();
//
//        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/hi3");
//        builder.queryParam("para1", "开发测试 001");
//        String url = builder.toUriString();
//
//        ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
//        System.out.println(forEntity.getBody());

        // 修复

        RestTemplate restTemplate = new RestTemplate();

        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/hi3");
        builder.queryParam("para1", "开发测试 001");
        String url = builder.toUriString();

        ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
        System.out.println(forEntity.getBody());
    }
}
